C
C     ..................................................................
C
C        SUBROUTINE ARRAY
C
C        PURPOSE
C           CONVERT DATA ARRAY FROM SINGLE TO DOUBLE DIMENSION OR VICE
C           VERSA.  THIS SUBROUTINE IS USED TO LINK THE USER PROGRAM
C           WHICH HAS DOUBLE DIMENSION ARRAYS AND THE SSP SUBROUTINES
C           WHICH OPERATE ON ARRAYS OF DATA IN A VECTOR FASHION.
C
C        USAGE
C           CALL ARRAY (MODE,I,J,N,M,S,D)
C
C        DESCRIPTION OF PARAMETERS
C           MODE - CODE INDICATING TYPE OF CONVERSION
C                    1 - FROM SINGLE TO DOUBLE DIMENSION
C                    2 - FROM DOUBLE TO SINGLE DIMENSION
C           I    - NUMBER OF ROWS IN ACTUAL DATA MATRIX
C           J    - NUMBER OF COLUMNS IN ACTUAL DATA MATRIX
C           N    - NUMBER OF ROWS SPECIFIED FOR THE MATRIX D IN
C                  DIMENSION STATEMENT
C           M    - NUMBER OF COLUMNS SPECIFIED FOR THE MATRIX D IN
C                  DIMENSION STATEMENT
C           S    - IF MODE=1, THIS VECTOR IS INPUT WHICH CONTAINS THE
C                  ELEMENTS OF A DATA MATRIX OF SIZE I BY J. COLUMN I+1
C                  OF DATA MATRIX FOLLOWS COLUMN I, ETC. IF MODE=2,
C                  THIS VECTOR IS OUTPUT REPRESENTING A DATA MATRIX OF
C                  SIZE I BY J CONTAINING ITS COLUMNS CONSECUTIVELY.
C                  THE LENGTH OF S IS IJ, WHERE IJ=I*J.
C           D    - IF MODE=1, THIS MATRIX OF SIZE N BY M IS OUTPUT,
C                  CONTAINING A DATA MATRIX OF SIZE I BY J IN THE FIRST
C                  I ROWS AND J COLUMNS. IF MODE=2, THIS N BY M MATRIX
C                  IS INPUT CONTAINING A DATA MATRIX OF SIZE I BY J IN
C                  THE FIRST I ROWS AND J COLUMNS.
C
C        REMARKS
C           VECTOR S CAN BE IN THE SAME LOCATION AS MATRIX D.  VECTOR S
C           IS REFERRED AS A MATRIX IN OTHER SSP ROUTINES, SINCE IT
C           CONTAINS A DATA MATRIX.
C           THIS SUBROUTINE CONVERTS ONLY GENERAL DATA MATRICES (STORAGE
C           MODE OF 0).
C
C        SUBROUTINES AND FUNCTION SUBROUTINES REQUIRED
C           NONE
C
C        METHOD
C           REFER TO THE DISCUSSION ON VARIABLE DATA SIZE IN THE SECTION
C           DESCRIBING OVERALL RULES FOR USAGE IN THIS MANUAL.
C
C     ..................................................................
C
      SUBROUTINE ARRAY (MODE,I,J,N,M,S,D)
      DIMENSION S(1),D(1)
C
      NI=N-I
C
C        TEST TYPE OF CONVERSION
C
      IF(MODE-1) 100, 100, 120
C
C        CONVERT FROM SINGLE TO DOUBLE DIMENSION
C
  100 IJ=I*J+1
      NM=N*J+1
      DO 110 K=1,J
      NM=NM-NI
      DO 110 L=1,I
      IJ=IJ-1
      NM=NM-1
  110 D(NM)=S(IJ)
      GO TO 140
C
C        CONVERT FROM DOUBLE TO SINGLE DIMENSION
C
  120 IJ=0
      NM=0
      DO 130 K=1,J
      DO 125 L=1,I
      IJ=IJ+1
      NM=NM+1
  125 S(IJ)=D(NM)
  130 NM=NM+NI
C
  140 RETURN
      END
